package com.tlx.design.factory.abstr;

import com.tlx.design.factory.Car;

public abstract class AbstractFactory {
    abstract Car getCar();

    //这段代码就是动态配置的功能
    //固定模式的委派
    public Car getCar(String name) {
        if (name.equalsIgnoreCase("BMW")) {
            return new BenzFactory().getCar();
        } else if (name.equalsIgnoreCase("Benz")) {
            return new BenzFactory().getCar();
        } else if (name.equalsIgnoreCase("Audi")) {
            return new AudiFactory().getCar();
        }
        return null;
    }
}
